<div id="information">
<br /><br />
<?php
$id = (int)$_GET['id'];


/* защита по ид */

if(!isset($id) || !is_numeric($id) || $id<1){
	echo "<h2>Немога да намера страницата..</h2>";
} else {
	$select_db_termin = mysql_query("SELECT * FROM termin_user WHERE id = '".$id."'");
	$row_ter = mysql_fetch_assoc($select_db_termin);
?>
<form method="post" action="" class="form">
	
	
    <table border="0" style="border-collapse: collapse; margin-left: 45px;" width="520px">
      <tr style="background-color: #ddd;"><td align="right" style="width: 100px;"><p><b>От:</b></p></td><td align="left" style="padding-left: 20px;"><?php echo $row_ter['username']; ?></td></tr>
	  <tr><td colspan="2"><hr /></td></tr>
	  
	  
	
	  <tr style="background-color: #ddd;"><td align="right"><p><b>Термин:</b></p></td><td align="left" style="padding-left: 20px;"><?php echo $row_ter['termin']; ?></td></tr>
	  
	  
	 
	  <tr><td colspan="2"><hr /></td></tr>
	  <tr style="background-color: #ddd;"><td align="right"><p><b>Описание:</b></p></td><td align="left" style="padding-left: 20px;"><?php echo $row_ter['opisanie']; ?></td></tr>
	  
	  
	  <tr><td colspan="2"><hr /></td></tr>
	  <tr style="background-color: #ddd;"><td align="right"><p><b>Категория:</b></p></td><td align="left" style="padding-left: 20px;"> <p><select name="cat" >
	   <option value="А">А</option>
	   <option value="Б">Б</option>
	   <option value="В">В</option>
	   <option value="Г">Г</option>
	   <option value="Д">Д</option>
	   <option value="Е">Е</option>
	   <option value="Ж">Ж</option>
	   <option value="З">З</option>
	   <option value="И">И</option>
	   <option value="Й">Й</option>
	   <option value="К">К</option>
	   <option value="Л">Л</option>
	   <option value="М">М</option>
	   <option value="Н">Н</option>
	   <option value="О">О</option>
	   <option value="П">П</option>
	   <option value="Р">Р</option>
	   <option value="С">С</option>
	   <option value="Т">Т</option>
	   <option value="У">У</option>
	   <option value="Ф">Ф</option>
	   <option value="Х">Х</option>
	   <option value="Ц">Ц</option>
	   <option value="Ч">Ч</option>
	   <option value="Ш">Ш</option>
	   <option value="Щ">Щ</option>
	   <option value="Ю">Ю</option>
	   <option value="Я">Я</option>
	</select></p></td></tr>
	
	 <tr><td colspan="2"><hr /></td></tr>
	  <tr style="background-color: #ddd;"><td></td><td><input type="submit" name="submit_yes" value="Качи термина" style='float:right;margin-right: 10px;'/>
		<a href='includes/no.php?id=<?php echo $id; ?>'></a></td></tr>
    </table>  
	</form>
<?php


	$sel_u = mysql_query('SELECT teacher_to FROM users WHERE username = "'.$_SESSION['username'].'"');
	$row_u = mysql_fetch_assoc($sel_u);
	
	
	$time=time();
	$cat=$_POST['cat'];
	$from_who = $row_ter['username'];
	$term = $row_ter['termin'];
	$dict_descr = $row_ter['opisanie'];
	
	
	if($_POST['submit_yes']) {
	
		$insert_into_dict=mysql_query('INSERT INTO termin(term, term_descr, cat, date_added, from_who, module)
							VALUES("'.$term.'","'.$dict_descr.'","'.$cat.'",'.$time.',"'.$from_who.'", "'.$row_u['teacher_to'].'")') or die(mysql_error());
		$update = mysql_query("UPDATE termin_user SET chek='1' WHERE id='".$id."'");
		
		if($insert_into_dict) {
			echo '<p class="success">Успешен запис!</p>';
		}
	}

}
?>
</div>